package dict

var ReportGroupBy = make(map[string][]string)

func _genGroupByKey(reportType ReportType, product AdProductType) string {
	return product.Name + string(reportType)
}

func _addReportGroupBy(reportType ReportType, product AdProductType, value ...string) {
	if len(value) == 0 {
		return
	}
	var key = _genGroupByKey(reportType, product)
	ReportGroupBy[key] = value
}

func GetGroupBy(reportType ReportType, product AdProductType) []string {
	var key = _genGroupByKey(reportType, product)
	return ReportGroupBy[key]
}

func init() {
	_addReportGroupBy(Campaign, AdProduct, "campaign", "adGroup")
	_addReportGroupBy(Campaign, AdBrand, "campaign")
	_addReportGroupBy(Campaign, AdDisplay, "campaign")

	_addReportGroupBy(AdGroup, AdBrand, "adGroup")
	_addReportGroupBy(AdGroup, AdDisplay, "adGroup")

	_addReportGroupBy(Audience, AdProduct, "campaign_bid_boost_segment")
	_addReportGroupBy(Audience, AdBrand, "campaign_bid_boost_segment")

	_addReportGroupBy(Placement, AdBrand, "campaign")

	_addReportGroupBy(Targeting, AdProduct, "targeting")
	_addReportGroupBy(Targeting, AdBrand, "targeting")
	_addReportGroupBy(Targeting, AdDisplay, "targeting")

	_addReportGroupBy(SearchTerm, AdProduct, "searchTerm")
	_addReportGroupBy(SearchTerm, AdBrand, "searchTerm")

	_addReportGroupBy(AdvertisedProduct, AdProduct, "advertiser")
	_addReportGroupBy(AdvertisedProduct, AdDisplay, "advertiser")

	_addReportGroupBy(Ad, AdBrand, "ads")

	_addReportGroupBy(PurchasedProduct, AdProduct, "asin")
	_addReportGroupBy(PurchasedProduct, AdBrand, "purchasedAsin")
	_addReportGroupBy(PurchasedProduct, AdDisplay, "asin")

	_addReportGroupBy(GrossAndValidTraffic, AdProduct, "campaign")
	_addReportGroupBy(GrossAndValidTraffic, AdBrand, "campaign")
	_addReportGroupBy(GrossAndValidTraffic, AdDisplay, "campaign")
}
